package com.ruoyi.classai.mapper;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.classai.domain.AnalysisModeRel;
import com.github.yulichang.base.MPJBaseMapper;
import com.ruoyi.classai.domain.EwcCourseGrouping;
import com.ruoyi.classai.domain.GroupStudentDetail;
import com.ruoyi.classai.domain.QueryAiMsg;
import com.ruoyi.classai.domain.dto.ModuleLessonPreparationModificationDto;
import com.ruoyi.classai.domain.vo.CourseGroupingRank;
import com.ruoyi.classai.domain.vo.GroupDetailVo;
import feign.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 课程分组Mapper接口
 * 
 * @author lcj
 * @date 2025-02-28
 */
public interface EwcCourseGroupingMapper extends BaseMapper<EwcCourseGrouping>, MPJBaseMapper<EwcCourseGrouping> {
    @Select("SELECT COUNT(DISTINCT sort) FROM ewc_course_grouping where class_id=#{classId} and course_id=#{courseId} and group_number=#{groupNumber} and chapter_id=#{chapterId}")
    Long selectDistinctClassIdCount(Map<String, Object> params);

    @Select("SELECT AVG(score) FROM ewc_course_grouping ${customSqlSegment}")
    Long getAvg(Map<String, Object> params);

    List<CourseGroupingRank> getCourseGroupingRank(ModuleLessonPreparationModificationDto moduleLessonPreparationModificationDto);

    List<GroupStudentDetail> queryGroupDetail(ModuleLessonPreparationModificationDto moduleLessonPreparationModificationDto);

    QueryAiMsg queryAiMsgg(AnalysisModeRel analysisModeRel);

    int querMaxGrouping(ModuleLessonPreparationModificationDto moduleLessonPreparationModificationDto);

    /**
     * 统计小组分组
     * @param chapterId 章节id
     * @return List
     */
    List<Integer> getGroupNum(@Param String chapterId);
}
